$(function(){
	$("#btn_login").on("click",function(){
		var name = $('#username').val();
		var pwd = $('#password').val();
		$(".error_login").hide();
		if(name.trim() == "" && pwd.trim() == ""){
			$("#no_name_pwd").show();
			$('#password').val("");
		}else if(name.trim() == "" && pwd.trim() != ""){
			$("#no_name").show();
			$('#password').val("");
		}else if(name.trim() != "" && pwd.trim() == ""){
			$("#no_pwd").show();
			$('#password').val("");
		}else{
			var data = {
		        username: $('#username').val(),
		        password: hex_md5($('#password').val())
		    };

		    getInterfaceInfo({
		        url: interfaces.login,
		        data: data
		    }, function (data,parm) {
				if(parm.errorCode == 0){
					window.location.href="./teacher.html?type=teacher";
				}else if(parm.errorCode == 4){
					$("#stop").hide();
					$("#error").show();
					$('#password').val("");
				}else if(parm.errorCode == 5){
					$("#error").hide();
					$("#stop").show();
					$('#password').val("");
				}  
		    });
		}


		
	});
	$('body').keydown(function (ev) {
        switch(ev.keyCode){
            case 13 :
                $("#btn_login").trigger('click');
                break;
        }
    });

	
});
		
 
